package com.cy.game

import android.content.Context
import android.widget.TextView
import com.helloandroid.R
import com.helloandroid.app.model.AppCache
import com.helloandroid.base.BaseDialog

class ExplainDialog(ctx:Context,val p:Proverb) : BaseDialog(ctx) {

    lateinit var tvTitle:TextView
    lateinit var tvTitlePinYin:TextView
    lateinit var tvExplain :TextView
    lateinit var tvSrc:TextView

    override fun getContentViewResId(): Int  = R.layout.yh_chengyu_content

    override fun initView() {
        tvTitle = findViewById(R.id.chengYu_title_han)
        tvTitlePinYin = findViewById(R.id.chengYu_title_pin)
        tvExplain = findViewById(R.id.chengyu_expainText)
        tvSrc = findViewById(R.id.chengyu_srouceText)

        val jsonObj = AppCache.allExplainJsonObj!!.getJSONObject(p.content)
        tvTitle.text = "${p.content}"
        tvTitlePinYin.text = "${jsonObj.getString("p")}"
        tvExplain.text = "${jsonObj.getString("e")}"
        tvSrc.text = "${jsonObj.getString("s")}"

        findBtn(R.id.chengYu_okButton).setOnClickListener {
            cancel()
        }
    }

    override fun initData() {
    }
}